<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/views/common/taglibs.jsp" %>

<!DOCTYPE>
<html>
<head>
    <!-- 引入通用js、css文件(xiaogq) -->
    <meta name="decorator" content="bootstrap"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/common/login.css"/>
</head>

<body>
    <div class="cotent" style="position: absolute;top: 50%;left: 50%;margin-left: -400px;margin-top: -188px;">
        <div style="padding: 60px 140px;width: 760px;background-color: rgba(255,255,255,0.6);margin: 0 auto;">
            <div class="mn-name">
                <input class="form-control" type="text" id="username" name="username" placeholder="请输入用户名" onkeydown="keyLoginIn();"/>
            </div>
            <div class="mn-password">
                <input class="form-control" type="password" id="password" name="password" placeholder="请输入密码" onkeydown="keyLoginIn();"/>
            </div>
            <div class="checkbox">
                <label><input type="checkbox"> 记住密码</label>
            </div>
            <div style="padding-top: 10px;">
                <button class="btn btn-success userLogin" style="width: 100%;" onclick="login();">立即登录</button>
            </div>
        </div>
        <div style="color: #708693;margin-top: 25px;">
            <p style="text-align: center;">全国统一咨询热线：400-47-2347(周末不休)</p>
            <p style="text-align: center;">Copyright© 2009-2016 长沙思齐教育咨询有限公司版权所有 湘ICP备12005327</p>
        </div>
    </div>

    <script type="text/javascript">
        /**
         * 用户登录方法(xiaogq)
         */
        function login(){
            $(".userLogin").button('loading');
            //获得用户名
            var loginName = $("#username").val();
            //获得登录密码
            var password = $("#password").val();
            if (loginName != "") {
                var pwd = password == "" ? "" : hex_md5(password);
                $.ajax({
                    type: "post",
                    url: "${ctx}/"+Constants.login,
                    data: "jobNumber=" + loginName + "&password="+ pwd,
                    datatype: "text",
                    success: function(data) {
                        $(".userLogin").button('reset');
                        if(data.success){
                            //将登陆名放入cookie中,这里设置的过期时间为30分钟
                            setCookie("siqitms_loginName",data.loginName,"m30");
                            // 连接新的界面
                            window.location.href = "${ctx}/"+Constants.loginModule+"?moduleid="+data.module.id;
                        }else{
                            alert(data.error,"error");
                        }
                    },
                    error: function(data) {
                        alert("数据连接失败，请刷新页面或稍后重试！");
                        $(".userLogin").button('reset');
                    }
                });
            }else{
                alert("请输入用户名！");
            }
        }

        //回车登录
        function keyLoginIn(event){
            var event = arguments.callee.caller.arguments[0] || window.event;
            if(event.keyCode == 13){
                $(".userLogin").click();
            }
        }
    </script>
    <!-- 引入md5密码加密js(xiaogq) -->
    <script type="text/javascript" src="${ctx}/js/widget/md5/md5.js"></script>
    <!-- 引入cookie设置通用js(xiaogq) -->
    <script type="text/javascript" src="${ctx}/js/common/setCookie.js"></script>
</body>
</html>
